from rest_framework import serializers
from .models import News,NewsCategory
from apps.xfzauth.serializers import UserSerializer
from .models import Comment,Banner


class NewsCategorySerializer(serializers.ModelSerializer):

    class Meta:
        model = NewsCategory
        fields = ('id','name')


class NewsSerializer(serializers.ModelSerializer):

    category = NewsCategorySerializer()
    author = UserSerializer()

    class Meta:
        model = News
        fields = ('id','title','desc','thumbnail','category','author','pub_time','content')


class CommentSerializer(serializers.ModelSerializer):
    class Meta:
        model = Comment
        fields = ('id','content','author','pub_time')


class BannerSerializer(serializers.ModelSerializer):
    class Meta:
        model = Banner
        fields = '__all__'